#!/usr/bin/env php
<?php
require_once __DIR__ . '/vendor/autoload.php';

 define('CURRENT_DIR', dirname(Phar::running(false)));


 $jian_config_path =  CURRENT_DIR . '/config/jian.conf.php';

 if (!file_exists($jian_config_path)) {
     echo '未检测jian.conf.php配置文件,请拷贝到jian应用的跟目录执行该脚本';
     exit;
 }
 Phar::mount('config.php', $jian_config_path);

 $jian_config = include __DIR__ . '/config.php';

 define('USER', $jian_config['mysql']['user']);
 define('PASS', $jian_config['mysql']['pass']);
 define('HOST', $jian_config['mysql']['host']);
 define('PORT', $jian_config['mysql']['port']);
 define('DBNAME', $jian_config['mysql']['dbname']);
 define('DIFFSQL', 'diff.sql');

$app = new \Symfony\Component\Console\Application('app', '1.0');

$app->addCommands([
    new \app\command\SchemaSourceCommand(),
    new \app\command\SchemaDiffCommand(),
    new \app\command\SchemaMigrateCommand()
]);
$app->run();
